package model;

import view.resources.Images;
import control.Storage;
import control.Util;

public class ImageSelector {

	private static ImageSelector selector;

	public static ImageSelector getInstance() {
		if (selector == null) {
			selector = new ImageSelector();
		}
		return selector;

	}

	private int random = 0;

	private int x = Storage.getInstance().getSize();

	private ImageSelector() {

	}

	public void buildImages() {

		Storage.getInstance().getImageMap().clear();
		Storage.getInstance().getCardMap().clear();

		calculateImages();

		random = 0;

	}

	private void calculateImages() {

		while (Storage.getInstance().getImageMap().size() < x * x / 2) {

			random = Util.getRandomNumber(1, 25);

			switch (random) {

			case 1:
				Storage.getInstance().getImageMap()
						.put(random, Images.APPLE.createImage());
				break;
			case 2:
				Storage.getInstance().getImageMap()
						.put(random, Images.BANANA.createImage());
				break;
			case 3:
				Storage.getInstance().getImageMap()
						.put(random, Images.BLACK_WHITECAT.createImage());
				break;
			case 4:
				Storage.getInstance().getImageMap()
						.put(random, Images.BLACKCAT.createImage());
				break;
			case 5:
				Storage.getInstance().getImageMap()
						.put(random, Images.BLUETOY.createImage());
				break;
			case 6:
				Storage.getInstance().getImageMap()
						.put(random, Images.BROWNCAT.createImage());
				break;
			case 7:
				Storage.getInstance().getImageMap()
						.put(random, Images.ELEPHANT.createImage());
				break;
			case 8:
				Storage.getInstance().getImageMap()
						.put(random, Images.FIRETOY.createImage());
				break;
			case 9:
				Storage.getInstance().getImageMap()
						.put(random, Images.GIRAFFE.createImage());
				break;
			case 10:
				Storage.getInstance().getImageMap()
						.put(random, Images.GORILLA.createImage());
				break;
			case 11:
				Storage.getInstance().getImageMap()
						.put(random, Images.GRAPE.createImage());
				break;
			case 12:
				Storage.getInstance().getImageMap()
						.put(random, Images.GRAYCAT.createImage());
				break;
			case 13:
				Storage.getInstance().getImageMap()
						.put(random, Images.GREENTOY.createImage());
				break;
			case 14:
				Storage.getInstance().getImageMap()
						.put(random, Images.LION.createImage());
				break;
			case 15:
				Storage.getInstance().getImageMap()
						.put(random, Images.NINJATOY.createImage());
				break;
			case 16:
				Storage.getInstance().getImageMap()
						.put(random, Images.ORANGE.createImage());
				break;
			case 17:
				Storage.getInstance().getImageMap()
						.put(random, Images.ORANGECAT.createImage());
				break;
			case 18:
				Storage.getInstance().getImageMap()
						.put(random, Images.PAPAYA.createImage());
				break;
			case 19:
				Storage.getInstance().getImageMap()
						.put(random, Images.PINEAPPLE.createImage());
				break;
			case 20:
				Storage.getInstance().getImageMap()
						.put(random, Images.PINKCAT.createImage());
				break;
			case 21:
				Storage.getInstance().getImageMap()
						.put(random, Images.STRAWBERRY.createImage());
				break;
			case 22:
				Storage.getInstance().getImageMap()
						.put(random, Images.WATERMELON.createImage());
				break;
			case 23:
				Storage.getInstance().getImageMap()
						.put(random, Images.YELLOWTOY.createImage());
				break;
			case 24:
				Storage.getInstance().getImageMap()
						.put(random, Images.ZEBRA.createImage());
				break;
			}

			Storage.getInstance().getCardMap().put(random, 0);

		}

	}

}
